package cn.source.event.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.source.common.annotation.Log;
import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.common.enums.BusinessType;
import cn.source.event.domain.DbYxsj;
import cn.source.event.service.IDbYxsjService;
import cn.source.common.utils.poi.ExcelUtil;
import cn.source.common.core.page.TableDataInfo;

/**
 * eventController
 * 
 * @author sourcebyte.vip
 * @date 2025-06-20
 */
@RestController
@RequestMapping("/event/yxsj")
public class DbYxsjController extends BaseController
{
    @Autowired
    private IDbYxsjService dbYxsjService;

    /**
     * 查询event列表
     */
    @PreAuthorize("@ss.hasPermi('event:yxsj:list')")
    @GetMapping("/list")
    public TableDataInfo list(DbYxsj dbYxsj)
    {
        startPage();
        List<DbYxsj> list = dbYxsjService.selectDbYxsjList(dbYxsj);
        return getDataTable(list);
    }

    /**
     * 导出event列表
     */
    @PreAuthorize("@ss.hasPermi('event:yxsj:export')")
    @Log(title = "event", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DbYxsj dbYxsj)
    {
        List<DbYxsj> list = dbYxsjService.selectDbYxsjList(dbYxsj);
        ExcelUtil<DbYxsj> util = new ExcelUtil<DbYxsj>(DbYxsj.class);
        util.exportExcel(response, list, "event数据");
    }

    /**
     * 获取event详细信息
     */
    @PreAuthorize("@ss.hasPermi('event:yxsj:query')")
    @GetMapping(value = "/{xh}")
    public AjaxResult getInfo(@PathVariable("xh") Long xh)
    {
        return AjaxResult.success(dbYxsjService.selectDbYxsjByXh(xh));
    }

    /**
     * 新增event
     */
    @PreAuthorize("@ss.hasPermi('event:yxsj:add')")
    @Log(title = "event", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DbYxsj dbYxsj)
    {
        return toAjax(dbYxsjService.insertDbYxsj(dbYxsj));
    }

    /**
     * 修改event
     */
    @PreAuthorize("@ss.hasPermi('event:yxsj:edit')")
    @Log(title = "event", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DbYxsj dbYxsj)
    {
        return toAjax(dbYxsjService.updateDbYxsj(dbYxsj));
    }

    /**
     * 删除event
     */
    @PreAuthorize("@ss.hasPermi('event:yxsj:remove')")
    @Log(title = "event", businessType = BusinessType.DELETE)
	@DeleteMapping("/{xhs}")
    public AjaxResult remove(@PathVariable Long[] xhs)
    {
        return toAjax(dbYxsjService.deleteDbYxsjByXhs(xhs));
    }
}
